import 'package:get/get.dart';
import 'package:mtf/app/data/UsdRecordEntity.dart';
import 'package:mtf/app/net/HttpManger.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
/**
 * GetX Template Generator - fb.com/htngu.99
 * */

class usd_recordController extends GetxController{
  var page =1;
  RefreshController refreshController = RefreshController(initialRefresh: true);
  RxList<ListUSDElement> usdList=<ListUSDElement>[].obs;
  void refreshData(){
    page=1;
    reqListData();
  }

  void loadData(){
    page+=1;
    reqListData();
  }
  void reqListData() async{
    var resp=await HttpManager.reqUsdRecord(page);
    if(resp.isSuccessData()){
      if(page==1){
        usdList.assignAll(resp.data!.list);
        refreshController.refreshCompleted();
      }else{
        usdList.addAll(resp.data!.list);
        if(resp.data!.list.isEmpty){
          refreshController.loadNoData();
        }else{
          refreshController.loadComplete();
        }
      }
    }
  }
}
